package org.example.auth.model.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.example.auth.enums.AuthorityType;
import org.example.misc.model.CommonEntity;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "auth_authority")
@org.hibernate.annotations.Table(appliesTo = "auth_authority", comment = "权限表")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Authority implements Serializable {

    private static final long serialVersionUID = -5746720355337387675L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false)
    private Long id;

    @Column
    private String code;

    private String name;

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private AuthorityType authorityType;

    @Column(nullable = false, unique = true)
    private String content;

    @Column
    private Long parentId;

    @Embedded
    private CommonEntity commonInfo;
}
